package com.adv.ems.model.dto;

import lombok.Data;

@Data
public class APIResponse <T>{
    private int code = 200;
    private T content;
    private String msg;
    private String devMsg;

    public static <T> APIResponse<T> build() {
        return new APIResponse<T>();
    }

    public static <T> APIResponse<T> businessError(int code, String msg) {
        APIResponse<T> tapiResponse = new APIResponse<>();
        tapiResponse.setCode(code);
        tapiResponse.setMsg(msg);
        return tapiResponse;
    }

    public static <T> APIResponse<T> businessError(String msg) {
        APIResponse<T> tapiResponse = new APIResponse<>();
        tapiResponse.setCode(500);
        tapiResponse.setMsg(msg);
        return tapiResponse;
    }

    public static <T> APIResponse<T> systemError(String msg, String devMsg) {
        APIResponse<T> tapiResponse = new APIResponse<>();
        tapiResponse.setCode(500);
        tapiResponse.setMsg(msg);
        tapiResponse.setDevMsg(devMsg);
        return tapiResponse;
    }

    public APIResponse <T> content(T content) {
        this.content = content;
        return this;
    }
}
